package com.ddn.controller.hall;
import com.ddn.util.OssUtil;
import com.ddn.util.R;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


import java.io.IOException;


@RestController
public class UploadController {

    /**
     * 图片上传文件
     * @param file
     * @return
     * @throws IOException
     */
    @RequestMapping("/upload")
    public R load(MultipartFile file) throws IOException {
        String picUrl = OssUtil.uploadFile(file.getInputStream(), file.getOriginalFilename());
        return picUrl != null ? R.ok().data("image",picUrl) : R.error().data("url","图片找不到了,请重新上传");
    }
}
